<extend name="Common@Base/layout"/>
<block name="body">

    <include file="Public/setleft"/>
    <div class="pside-toggle pside-hide"><i class="fa fa-angle-double-left"></i></div>
    <form id="paging_form" name="paging_form" method="post" action="/set/notice/index">
        <div class="pmain">
            <div class="main-content main-pagebar-content">
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-sm-12">
                            <h3 class="mod-title">
                                <span class="t">通知公告管理</span>
                            </h3>
                            <div class="panel panel-default">
                                <div class="panel-body panel-body-up-table">
                                    <div class="search-panel">
                                        <div class="search">
                                            <div class="dropdown btn-group">
                                                <a class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                                                    <span id="search_status_name" class="option-name">状态</span> <i class="fa fa-angle-down"></i></a>
                                                <ul class="dropdown-menu dropdown-option-menu">
                                                    <li><a data-value="" role="button">全部</a></li>
                                                    <li><a data-value="0" role="button">草稿</a></li>
                                                    <li><a data-value="1" role="button">已发布</a></li>
                                                </ul>
                                                <input id="search_status" name="search_status" class="option-value filter-item-value" type="hidden"
                                                       value="{$_page->parameter['search_status']}">
                                            </div>

                                            <div class="btn-group">
                                                <input name="search_key" type="text" class="form-control" value="{$_page->parameter['search_key']|urldecode}"
                                                       placeholder="请输入标题">
                                            </div>
                                            <div class="btn-group">
                                                <button type="submit">搜索</button>
                                            </div>
                                        </div>
                                        <div class="select-group">
                                            <a class="btn btn-operate-link" role="button" data-toggle="modal" data-target="#edit-notice"
                                               data-type="new-custom">添加通知</a>
                                        </div>
                                    </div>

                                </div>
                                <div class="table-responsive">
                                    <table class="table-check table-link-hover table table-striped table-bordered table-hover">
                                        <thead>
                                        <tr>
                                            <th>标题</th>
                                            <th>发布单位</th>
                                            <th style="width:6%" class="text-center">状态</th>
                                            <th style="width:8%">时间</th>
                                            <th style="width:8%" class="td-action">操作</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <volist name="notice_list" id="notice">
                                            <tr data-vid="{$notice.id}"
                                                data-title="{$notice.title}"
                                                data-promulgator="{$notice.promulgator}"
                                                data-attribute="{$notice.attribute}"
                                                data-rank="{$notice.rank}"
                                                data-status="{$notice.status}"
                                                data-content="{$notice.content}"
                                                data-annex_path="{$Think.config.UPLOAD_IMAGE_URL}{$notice.annex_path}"
                                                data-annex_name="{$notice.annex_name}">
                                                <td>
                                                    <div class="truncate" title="{$notice.title}">
                                                        {$notice.title}
                                                    </div>
                                                </td>
                                                <td>{$notice.promulgator}</td>
                                                <td class="text-center">{$notice.status|fc_get_config_value="TASK_STATUS"}</td>
                                                <td>{$notice.create_at|fc_get_date}</td>
                                                <td class="td-action">

                                                    <a class="td-btn" data-toggle="modal" data-target="#edit-notice" data-type="edit-info" role="button">编辑</a>

                                                        <a class="td-btn" data-type="delete-info" role="button">删除</a>

                                                </td>
                                            </tr>
                                        </volist>
                                        </tbody>
                                    </table>
                                    <input class="checked-item" type="hidden">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="main-pagebar">
                <include file="Common@Public/paging"/>
            </div>
        </div>
    </form>

    <include file="edit"/>

    <script>
        $(document).ready(function () {
            $('#nav-set').addClass("active");
            var vx = $("#search_status").val();
            if (vx != "") {
                $("#search_status").prev().find('a').each(function () {
                    var $this = $(this);
                    if ($this.data('value') == vx) {
                        $("#search_status_name").text($this.text());
                    }
                });
            }

            $('a[data-type="delete-info"]').click(function () {
                var $tr = $(this).parent().parent();
                alertify.confirm("确定操作？", function (e) {
                    if (e) {
                        var url = "/set/notice/delete";
                        var data = "id=" + $tr.attr('data-vid');
                        $.ajax({
                            type: "GET",
                            url: url,
                            data: data,
                            success: function (data) {
                                if (data == "0") {
                                    alertify.alert("操作成功!", function () {
                                        location.reload();
                                    });

                                } else {
                                    alertify.alert("操作失败!");
                                }
                            }
                        });
                    }
                });
            });
        });
    </script>
</block>